namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0032 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.IcmInventoryRepair",
                c => new
                    {
                        RepairId = c.Int(nullable: false, identity: true),
                        AssetCode = c.String(),
                        DealerRepairId = c.Int(),
                        JobSiteId = c.Int(),
                        WhId = c.Int(),
                        RepairDate = c.DateTime(),
                        RepairDescr = c.String(),
                        Cause = c.String(),
                        RepairRemark = c.String(),
                        ReceiveDate = c.DateTime(),
                        RepairAmount = c.Double(),
                        RepairDiscount = c.Double(),
                        RepairStatus = c.String(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.RepairId)
                .ForeignKey("dbo.IcmMasDealerRepair", t => t.DealerRepairId)
                .ForeignKey("dbo.hrm_mp_job_sites", t => t.JobSiteId)
                .ForeignKey("dbo.IcmWarehouse", t => t.WhId)
                .Index(t => t.DealerRepairId)
                .Index(t => t.JobSiteId)
                .Index(t => t.WhId);
            
            CreateTable(
                "dbo.IcmMasDealerRepair",
                c => new
                    {
                        DealerRepairId = c.Int(nullable: false, identity: true),
                        DealerRepairName = c.String(),
                        DealerAddress = c.String(),
                        Remark = c.String(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.DealerRepairId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.IcmInventoryRepair", new[] { "WhId" });
            DropIndex("dbo.IcmInventoryRepair", new[] { "JobSiteId" });
            DropIndex("dbo.IcmInventoryRepair", new[] { "DealerRepairId" });
            DropForeignKey("dbo.IcmInventoryRepair", "WhId", "dbo.IcmWarehouse");
            DropForeignKey("dbo.IcmInventoryRepair", "JobSiteId", "dbo.hrm_mp_job_sites");
            DropForeignKey("dbo.IcmInventoryRepair", "DealerRepairId", "dbo.IcmMasDealerRepair");
            DropTable("dbo.IcmMasDealerRepair");
            DropTable("dbo.IcmInventoryRepair");
        }
    }
}
